package com.airspyar;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class ScalingImageView extends ImageView {
	
  public ScalingImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  @Override protected void onMeasure(int widthMeasureSpec,
      int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    
    Drawable drawable=this.getDrawable();
    if(drawable!=null)
    	height = width * drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth();
    
	setMeasuredDimension(width, height);
  }
}
